#ifndef _BUTTON_
#define _BUTTON_

#include "Object.h"

#include "hge\hgefont.h"
#include "hge\hgesprite.h"
#include "hge\hgecolor.h"
#include "hge\hgeresource.h"

namespace air {
	struct Event;
	class SceneManager;

	class Button: public IGuiObject
	{
	public:
		/**
		 * @brief Constructor
		 *	
		 * @param hgeResMan hgeResourceManager
		 * @param _id	gui_id to assign
		 * @param _x 	absolute horizontal position
		 * @param _y 	absolute vertical position
		 * @param _delay	time to be waited before displayed
		 * @param _title	word showed on the button
		 */
		Button(hgeResourceManager* hgeResMan, float _x, float _y, float _delay, char *_title, Event* _evnt = NULL);
		Button(hgeResourceManager* hgeResMan, float _delay, char *_title, Event* _evnt = NULL);
		/**
		 * @brief Button Render
		 */
		virtual void Render();
		/**
		 * @brief Animation Process
		 *
		 * @param dt
		 */
		virtual void Update(float dt);
		/**
		 * @brief callback before button appear on screen
		 */
		virtual void Enter();
		/**
		 * @brief callback before button disappear from screen
		 */
		virtual void Leave();
		/**
		 * @brief check whether button has finished appear / disappear action
		 *
		 * @return true when finish, otherwise false
		 */
		virtual bool IsDone();
		/**
		 * @brief callback when button lost or get focus
		 *
		 * @param bFocused true when get focus, false when newly lost focus
		 */
		virtual void Focus(bool bFocused);
		/**
		 * @brief callback when mouse move in or move out button
		 *
		 * @param bOver true when mouse on Button, otherwise false
		 */
		virtual void MouseOver(bool bOver);

		/**
		 * @brief callback when lmouse status changed on button
		 *
		 * @param bDown new lmouse status
		 *
		 * @param whether to notify the button action
		 */
		virtual bool MouseLButton(bool bDown);
		/**
		 * @brief callback when key pressed
		 *
		 * @param key	key value
		 * @param chr
		 *
		 * @return 
		 */
		virtual bool KeyClick(int key, int chr);

		/**
		 * @brief add button to gui
		 *
		 * @param pointer to SceneManager
		 * @param anchorPoint specify the object' s anchor
		 *
		 * @return whether success
		 */
		bool addToGui(SceneManager* sceneMan, IGuiObject* _anchor);

		void SetTitle(char* _title) { title = _title; }
	private:
		hgeFont		*fnt;
		/**
		 * @brief time to delay befor disappear on screen
		 */
		float		delay;
		/**
		 * @brief word displayed on button
		 */
		char		*title;
		hgeColor	scolor, dcolor, scolor2, dcolor2, sshadow, dshadow;
		hgeColor	color, shadow;
		float		soffset, doffset, offset;
		float		timer, timer2;

		/**
		 * @brief event to trigger when pressed button
		 */
		Event*	evnt;

	};
}

#endif
